﻿using Newtonsoft.Json;

namespace SmartAgricultureService.Models
{
    public sealed class AjaxResult<T>
    {
        public AjaxResult() { }
        public AjaxResult(T result)
        {
            Success = true;
            Result = result;
        }
        public AjaxResult(Exception exception)
        {
            Success = false;
            Message = exception.Message;
        }
        public bool Success { get; set; }
        public T Result { get; set; }
        public string Message { get; set; } = string.Empty;
        public override string ToString()
            => JsonConvert.SerializeObject(this);
    }
}